<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from '../components/HelloWorld.vue'
import {useCounterStore} from '@/stores/counter'
const store = useCounterStore()
import { useRouter } from 'vue-router';
const router = useRouter()

const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
import { ref } from 'vue'
const activeIndex2 = ref('1')
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const add=()=>{
  router.push('/product')
}
const show=()=>{
  router.push('/details')
}

const out=()=>{
  router.push('/')
}
</script>

<template>
  <div class="common-layout" style="width: 1300px;font-size: 20px;height: 800px;">
    <el-container>
      <el-header  style="background-color: #545c64;">
        <el-menu
    :default-active="activeIndex2"
    class="el-menu-demo"
    mode="horizontal"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    @select="handleSelect"
    style="width: 1200px;"
  >
    <el-menu-item index="1">成都爱吃兔食品加工有限公司</el-menu-item>
    <el-sub-menu index="2">
      <template #title>菜单</template>
      <el-menu-item index="/user">权限管理</el-menu-item>
      <el-menu-item index="2-2">角色管理</el-menu-item>
      <el-menu-item index="2-3">人员管理</el-menu-item>
    </el-sub-menu>
    <el-menu-item index="3" style="font-size: 20px;" disabled></el-menu-item>
    <el-menu-item index="5" style="margin-left: 250px;">
      当前登录人：<span style="color: #ffd04b;">{{ store.counterAccount.accountNicName }}</span>&nbsp;&nbsp;&nbsp;
    角色：<span style="color: #ffd04b;">{{ store.counterAccount.accountRoleName }}</span>
    <div style="margin: 20px;">
      <el-avatar> {{ store.counterAccount.accountNicName }} </el-avatar>
    </div>
    </el-menu-item>
    <el-menu-item style="margin-right: 0px;">
          <el-icon><SwitchButton /></el-icon>
          <span @click="out()">退出登录</span>
        </el-menu-item> 
  </el-menu>
      </el-header>
      <el-container>
        <el-aside width="200px"  style="background-color: #545c64;">
          <el-row class="tac">
            <el-col :span="30" style="height: 480px;width: 320px;">
      <el-menu
        active-text-color="#ffd04b"
        background-color="#545c64"
        class="el-menu-vertical-demo"
        default-active="3"
        text-color="#fff"
        @open="handleOpen"
        @close="handleClose"
      >
        <el-sub-menu index="1" v-show="store.counterAccount.accountId==1">
          <template #title>
            <el-icon><Smoking /></el-icon>
            <span>溯源管理</span>
          </template>
            <el-menu-item index="1-1" @click="add()">溯源基本信息</el-menu-item>
            <el-menu-item index="1-2" @click="show()">溯源详情</el-menu-item>
        </el-sub-menu>
        <!-- <el-sub-menu index="2" v-show="store.counterAccount.accountId==1||2">
          <template #title>
            <el-icon><User /></el-icon>
            <span>角色管理</span>
          </template>

            <el-menu-item index="1-1" @click="addrole()">新增角色</el-menu-item>
            <el-menu-item index="1-2" @click="showrole()">角色列表</el-menu-item>

        </el-sub-menu>
        <el-sub-menu index="3" v-show="store.counterAccount.accountId==1||2">
          <template #title>
            <el-icon><Avatar /></el-icon>
            <span>人员管理</span>
          </template>

            <el-menu-item index="1-1" @click="adduser()">新增人员</el-menu-item>
            <el-menu-item index="1-2" @click="showuser()">人员列表</el-menu-item>

        </el-sub-menu>
        <el-sub-menu index="4" v-show="store.counterAccount.accountId==1">
          <template #title>
            <el-icon><Management /></el-icon>
            <span>字典管理</span>
          </template>

            <el-menu-item index="1-1" @click="showdicttype()">类型列表</el-menu-item>
            <el-menu-item index="1-3" @click="adddicttype()">添加类型</el-menu-item>
            <el-menu-item index="1-4" @click="showdictitem()">明细列表</el-menu-item>
            <el-menu-item index="1-5" @click="adddictitem()">添加明细</el-menu-item>
        </el-sub-menu> -->
      </el-menu>
    </el-col>
          </el-row>
        </el-aside>
        <el-main style="background-color: whitesmoke;">
          <header>
            <!-- <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" /> -->

    <div class="wrapper">
      <!-- <HelloWorld msg="You did it!" /> -->

      <nav>
        <!-- <RouterLink to="/">Home</RouterLink>
        <RouterLink to="/about">About</RouterLink> -->
      </nav>
    </div>
  </header>
  <RouterView />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style scoped>
header {
  line-height: 1.5;
  max-height: 100vh;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

nav {
  width: 100%;
  font-size: 12px;
  text-align: center;
  margin-top: 2rem;
}

nav a.router-link-exact-active {
  color: var(--color-text);
}

nav a.router-link-exact-active:hover {
  background-color: transparent;
}

nav a {
  display: inline-block;
  padding: 0 1rem;
  border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
  border: 0;
}

@media (min-width: 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
  }

  nav {
    text-align: left;
    margin-left: -1rem;
    font-size: 1rem;

    padding: 1rem 0;
    margin-top: 1rem;
  }
}
</style>
